1. 首页 > 宝宝起名

宝宝取名网不收费起名字打分

请输入宝宝的姓名,我们将为您免费打分。

const submitButton = document.getElementById("submit-button");const result = document.getElementById("result");submitButton.addEventListener("click", (e) => {e.preventDefault();const firstName = document.getElementById("first-name").value;const lastName = document.getElementById("last-name").value;if (firstName === "" || lastName === "") {alert("请输入宝宝的姓名。");return;}const score = calculateScore(firstName, lastName);result.innerHTML = `宝宝的名字 "${firstName}${lastName}" 的得分是 ${score} 分。`;});function calculateScore(firstName, lastName) {let score = 0;// 拼音首字母得分const pinyinFirstLetters = getPinYinFirstLetters(firstName, lastName);score += calculatePinyinFirstLettersScore(pinyinFirstLetters);// 五行得分const wuxingScore = calculateWuxingScore(firstName, lastName);score += wuxingScore;// 笔画得分const strokesScore = calculateStrokesScore(firstName, lastName);score += strokesScore;// 字义得分const meaningScore = calculateMeaningScore(firstName, lastName);score += meaningScore;// 音律得分const rhythmScore = calculateRhythmScore(firstName, lastName);score += rhythmScore;// 寓意得分const implicationScore = calculateImplicationScore(firstName, lastName);score += implicationScore;return score;}// 计算拼音首字母得分function calculatePinyinFirstLettersScore(pinyinFirstLetters) {const goodPinyinFirstLetters = ["A", "F", "G", "H", "L", "M", "Q", "R", "T", "W", "X", "Y"];let score = 0;for (const letter of pinyinFirstLetters) {if (goodPinyinFirstLetters.includes(letter)) {score += 1;}}return score 10;}// 获取姓氏和名字的拼音首字母function getPinYinFirstLetters(firstName, lastName) {const pinyin = require("pinyin");const lastNamePinyin = pinyin(lastName, { style: pinyin.STYLE_FIRST_LETTER });const firstNamePinyin = pinyin(firstName, { style: pinyin.STYLE_FIRST_LETTER });return lastNamePinyin[0] + firstNamePinyin[0];}// 计算五行得分function calculateWuxingScore(firstName, lastName) {const wuxing = {火: ["火", "炎", "日", "阳", "赤", "朱", "彤", "暖", "焦", "热", "爆", "炒", "煎", "炸"],木: ["木", "林", "森", "东", "青", "翠", "绿", "萌", "芽", "生", "长", "发", "育", "茁"],金: ["金", "铁", "钢", "西", "白", "银", "灰", "坚", "刚", "硬", "锐", "利", "锋", "裁"],水: ["水", "川", "河", "湖", "海", "黑", "蓝", "润", "湿", "冷", "清", "凉", "寒", "冰"],土: ["土", "地", "山", "石", "黄", "棕", "灰", "厚", "重", "实", "稳", "牢", "固", "建"],};let score = 0;for (const element in wuxing) {if (firstName.includes(wuxing[element]) || lastName.includes(wuxing[element])) {score += 1;}}return score 10;}// 计算 笔画得分function calculateStrokesScore(firstName, lastName) {const strokes = require("chinese-unicode-strokes");const firstNameStrokes = strokes.count(firstName);const lastNameStrokes = strokes.count(lastName);return (firstNameStrokes + lastNameStrokes) 5;}// 计算字义得分function calculateMeaningScore(firstName, lastName) {const meaning = require("chinese-character-meaning");const firstNameMeaning = meaning.get(firstName);const lastNameMeaning = meaning.get(lastName);let score = 0;if (firstNameMeaning.some((m) => m.includes("美")) || lastNameMeaning.some((m) => m.includes("美"))) {score += 1;}if (firstNameMeaning.some((m) => m.includes("德")) || lastNameMeaning.some((m) => m.includes("德"))) {score += 1;}if (firstNameMeaning.some((m) => m.includes("才")) || lastNameMeaning.some((m) => m.includes("才"))) {score += 1;}if (firstNameMeaning.some((m) => m.includes("福")) || lastNameMeaning.some((m) => m.includes("福"))) {score += 1;}if (firstNameMeaning.some((m) => m.includes("寿")) || lastNameMeaning.some((m) => m.includes("寿"))) {score += 1;}if (firstNameMeaning.some((m) => m.includes("康")) || lastNameMeaning.some((m) => m.includes("康"))) {score += 1;}if (firstNameMeaning.some((m) => m.includes("宁")) || lastNameMeaning.some((m) => m.includes("宁"))) {score += 1;}return score 10;}// 计算音律得分function calculateRhythmScore(firstName, lastName) {const chinese = require("chinese-converter");const firstNamePinyin = chinese.convert(firstName, "pinyin");const lastNamePinyin = chinese.convert(lastName, "pinyin");const firstNameTone = firstNamePinyin.slice(-1);const lastNameTone = lastNamePinyin.slice(-1);let score = 0;if (firstNameTone === lastNameTone) {score += 1;}if (firstNameTone === "1" && lastNameTone === "3") {score += 1;}if (firstNameTone === "2" && lastNameTone === "4") {score += 1;}if (firstNameTone === "3" && lastNameTone === "2") {score